import os

# filename and coordinate
name = []   
coor = []

# get filename and coordinate
with open('../Data_Set/splits/train.txt') as f:
    num = 0
    for i in f.readlines():
        msg = i.strip().split('-')
        name.append(i.strip())

        # get the coor of bounding box
        m = msg[2].split('_') # [xxx&xxx, xxx&xxx]
        m1 = m[0].split('&')
        m1.extend(m[1].split('&'))  # [x1, y1, x2, y2]
        coor.append(m1)
        
# rewrite to new file
with open('./train_base.txt', 'w') as f:
    for n, c in zip(name, coor):
        f.writelines(f'{n} {c[0]} {c[1]} {c[2]} {c[3]}\n')
